package com.hmkj.Utils.mail;

import com.erps.CommonUtils.AppConfig;
import com.erps.CommonUtils.Config;

public class MailUtils {
	public static boolean send_mail(String cToMailAddr, String cSubject, String cContent) {
		String cMAIL_HOST = Config.ReadString(AppConfig.SMTP_HOST, "");
		String cMAIL_PORT = Config.ReadString(AppConfig.SMTP_PORT, "25");
		String cMAIL_USERNAME = Config.ReadString(AppConfig.SMTP_USER, "");
		String cMAIL_KEYWORD = Config.ReadString(AppConfig.SMTP_PASS, "");

		MailSenderInfo mailSenderInfo = new MailSenderInfo();
		mailSenderInfo.setMailServerHost(cMAIL_HOST); // 邮箱地址
		mailSenderInfo.setMailServerPort(cMAIL_PORT); // 邮箱端口
		mailSenderInfo.setValidate(true);
		mailSenderInfo.setUserName(cMAIL_USERNAME); // 你的用户名
		mailSenderInfo.setPassword(cMAIL_KEYWORD); // 你的密码
		mailSenderInfo.setFromAddress(cMAIL_USERNAME);
		mailSenderInfo.setToAddress(cToMailAddr); // 收邮件的地址

		mailSenderInfo.setSubject(cSubject);
		mailSenderInfo.setContent(cContent);

		// 创建一个邮件发送器
		MailSender Sender = new MailSender();
		// Boolean isSendFlag =
		// simpleMailSender.sendTextMail(mailSenderInfo);// 发送文本格式邮件
		return Sender.sendHtmlMail(mailSenderInfo);// 发送HTML格式邮件
	}
}
